using System;

namespace KodeIT.Web
{
    /// <summary>
    /// This class contains the names of the available server variable names in IIS.
    /// </summary>
    /// <remarks>
    /// It is possible to retrieve request headers with a "-" (dash) as well as "_" (underscore) by using the 
    /// "HEADER_" prefix. This is an improvement over the "HTTP_" prefix, which was unable to retrieve headers 
    /// with an '_' (underscore). i.e. If you had a request with the following two headers:
    /// 
    /// <list type="bullet">
    ///     <item>
    ///         <term>My_Header: Value1</term>
    ///     </item>
    ///     <item>
    ///         <term>My-Header: Value2</term>
    ///     </item>
    /// </list>
    /// 
    /// Using "HTTP_MY_HEADER" as the name, you will only retrieve "Value2". Meanwhile, using "HEADER_MY_HEADER" will
    /// get "Value1", and "HEADER_MY-HEADER" will get "Value2".
    /// </remarks>
    public static class ServerVariable
    {
        /// <summary>
        /// All HTTP headers sent by the client.
        /// </summary>
        public const string ALL_HTTP = "ALL_HTTP";

        /// <summary>
        /// Retrieves all headers in raw form. The difference between ALL_RAW and ALL_HTTP is that 
        /// ALL_HTTP places an HTTP_ prefix before the header name and the header name is always 
        /// capitalized. In ALL_RAW the header name and values appear as they are sent by the client.
        /// </summary>
        public const string ALL_RAW = "ALL_RAW";

        /// <summary>
        /// Returns the name of the application pool that is running in the IIS worker process that is handling the request. 
        /// There is also an APP_POOL_ID environment variable that is available to applications that are running in the 
        /// IIS worker process.
        /// </summary>
        /// <remarks>
        /// IIS 5.1 and earlier: This server variable is not available.
        /// </remarks>
        public const string APP_POOL_ID = "APP_POOL_ID";

        /// <summary>
        /// Retrieves the metabase path of the application.
        /// </summary>
        public const string APPL_MD_PATH = "APPL_MD_PATH";

        /// <summary>
        /// Retrieves the physical path corresponding to the metabase path in APPL_MD_PATH.
        /// </summary>
        public const string APPL_PHYSICAL_PATH = "APPL_PHYSICAL_PATH";

        /// <summary>
        /// The value entered in the client's authentication dialog. This variable is available only if 
        /// Basic authentication is used.
        /// </summary>
        public const string AUTH_PASSWORD = "AUTH_PASSWORD";

        /// <summary>
        /// The authentication method that the server uses to validate users when they attempt to access a protected script. 
        /// It does not mean that the user was authenticated if AUTH_TYPE contains a value and the authentication scheme 
        /// is not Basic or integrated Windows authentication. The server allows authentication schemes it does not 
        /// natively support because an HttpFilter may be able to handle that particular scheme.
        /// </summary>
        public const string AUTH_TYPE = "AUTH_TYPE";

        /// <summary>
        /// The name of the user as it is derived from the authorization header sent by the client, before the user 
        /// name is mapped to a Windows account. This variable is no different from REMOTE_USER. If you have 
        /// an authentication filter installed on your Web server that maps incoming users to accounts, use 
        /// LOGON_USER to view the mapped user name.
        /// </summary>
        public const string AUTH_USER = "AUTH_USER";

        /// <summary>
        /// Unique ID for the client certificate, returned as a string. This can be used as a signature for 
        /// the whole client certificate.
        /// </summary>
        public const string CERT_COOKIE = "CERT_COOKIE";

        /// <summary>
        /// bit0 is set to 1 if the client certificate is present. bit1 is set to 1 if the certification authority 
        /// of the client certificate is invalid (that is, it is not in the list of recognized certification 
        /// authorities on the server). If bit 1 of CERT_FLAGS is set to 1, indicating that the certificate is 
        /// invalid, IIS version 4.0 and later will reject the certificate. Earlier versions of IIS will not 
        /// reject the certificate.
        /// </summary>
        public const string CERT_FLAGS = "CERT_FLAGS";

        /// <summary>
        /// Issuer field of the client certificate (O=MS, OU=IAS, CN=user name, C=USA).
        /// </summary>
        public const string CERT_ISSUER = "CERT_ISSUER";

        /// <summary>
        /// Number of bits in the Secure Sockets Layer (SSL) connection key size. For example, 128.
        /// </summary>
        public const string CERT_KEYSIZE = "CERT_KEYSIZE";

        /// <summary>
        /// Number of bits in server certificate private key. For example, 1024.
        /// </summary>
        public const string CERT_SECRETKEYSIZE = "CERT_SECRETKEYSIZE";

        /// <summary>
        /// Serial number field of the client certificate.
        /// </summary>
        public const string CERT_SERIALNUMBER = "CERT_SERIALNUMBER";

        /// <summary>
        /// Issuer field of the server certificate.
        /// </summary>
        public const string CERT_SERVER_ISSUER = "CERT_SERVER_ISSUER";

        /// <summary>
        /// Subject field of the server certificate.
        /// </summary>
        public const string CERT_SERVER_SUBJECT = "CERT_SERVER_SUBJECT";

        /// <summary>
        /// Subject field of the client certificate.
        /// </summary>
        public const string CERT_SUBJECT = "CERT_SUBJECT";

        /// <summary>
        /// The length of the content as given by the client.
        /// </summary>
        public const string CONTENT_LENGTH = "CONTENT_LENGTH";

        /// <summary>
        /// The data type of the content. Used with queries that have attached information, such 
        /// as the HTTP queries GET, POST, and PUT.
        /// </summary>
        public const string CONTENT_TYPE = "CONTENT_TYPE";

        /// <summary>
        /// The revision of the CGI specification used by the server. The format is CGI/revision.
        /// </summary>
        public const string GATEWAY_INTERFACE = "GATEWAY_INTERFACE";

        /// <summary>
        /// Returns the value of the Accept header that contains a list of accepted formats, for example, 
        /// "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel". The values of 
        /// the fields for the HTTP_ACCEPT variable are concatenated, and separated by a comma (,).
        /// </summary>
        public const string HTTP_ACCEPT = "HTTP_ACCEPT";

        /// <summary>
        /// Returns a list of accepted encoding types, for example, "gzip, deflate".
        /// </summary>
        public const string HTTP_ACCEPT_ENCODING = "HTTP_ACCEPT_ENCODING";

        /// <summary>
        /// Returns a string describing the language to use for displaying content.
        /// </summary>
        public const string HTTP_ACCEPT_LANGUAGE = "HTTP_ACCEPT_LANGUAGE";

        /// <summary>
        /// Returns a string describing the connection type, for example, "Keep-Alive".
        /// </summary>
        public const string HTTP_CONNECTION = "HTTP_CONNECTION";

        /// <summary>
        /// Returns the cookie string that was included with the request.
        /// </summary>
        public const string HTTP_COOKIE = "HTTP_COOKIE";

        /// <summary>
        /// Returns the name of the Web server. This may or may not be the same as SERVER_NAME depending on 
        /// type of name resolution you are using on your Web server (IP address, host header).
        /// </summary>
        public const string HTTP_HOST = "HTTP_HOST";

        /// <summary>
        /// The method used to make the request (same as REQUEST_METHOD).
        /// </summary>
        public const string HTTP_METHOD = "HTTP_METHOD";

        /// <summary>
        /// Returns a string that contains the URL of the page that referred the request to the current page using an 
        /// HTML &lt;A&gt; tag. Note that the URL is the one that the user typed into the browser address bar, which 
        /// may not include the name of a default document. If the page is redirected, HTTP_REFERER is empty. 
        /// HTTP_REFERER is not a mandatory member of the HTTP specification.
        /// </summary>
        public const string HTTP_REFERER = "HTTP_REFERER";

        /// <summary>
        /// Returns the raw, encoded URL, for example, "/vdir/default.asp?querystring".
        /// </summary>
        public const string HTTP_URL = "HTTP_URL";

        /// <summary>
        /// Returns a string describing the browser that sent the request.
        /// </summary>
        public const string HTTP_USER_AGENT = "HTTP_USER_AGENT";

        /// <summary>
        /// The name and version of the request protocol (the raw form of SERVER_PROTOCOL).
        /// </summary>
        public const string HTTP_VERSION = "HTTP_VERSION";

        /// <summary>
        /// Returns ON if the request came in through a secure channel (for example, SSL); or it returns 
        /// OFF, if the request is for an insecure channel.
        /// </summary>
        public const string HTTPS = "HTTPS";

        /// <summary>
        /// Number of bits in the SSL connection key size. For example, 128.
        /// </summary>
        public const string HTTPS_KEYSIZE = "HTTPS_KEYSIZE";

        /// <summary>
        /// Number of bits in the server certificate private key. For example, 1024.
        /// </summary>
        public const string HTTPS_SECRETKEYSIZE = "HTTPS_SECRETKEYSIZE";

        /// <summary>
        /// Issuer field of the server certificate.
        /// </summary>
        public const string HTTPS_SERVER_ISSUER = "HTTPS_SERVER_ISSUER";

        /// <summary>
        /// Subject field of the server certificate.
        /// </summary>
        public const string HTTPS_SERVER_SUBJECT = "HTTPS_SERVER_SUBJECT";

        /// <summary>
        /// The ID for the IIS instance in textual format. If the instance ID is 1, it appears as a string. You 
        /// can use this variable to retrieve the ID of the Web server instance (in the metabase) to 
        /// which the request belongs.
        /// </summary>
        public const string INSTANCE_ID = "INSTANCE_ID";

        /// <summary>
        /// The metabase path for the instance of IIS that responds to the request.
        /// </summary>
        public const string INSTANCE_META_PATH = "INSTANCE_META_PATH";

        /// <summary>
        /// Returns the server address on which the request came in. This is important on computers where 
        /// there can be multiple IP addresses bound to the computer, and you want to find out which 
        /// address the request used.
        /// </summary>
        public const string LOCAL_ADDR = "LOCAL_ADDR";

        /// <summary>
        /// The Windows account that the user is impersonating while connected to your Web server. Use 
        /// REMOTE_USER, UNMAPPED_REMOTE_USER, or AUTH_USER to view the raw user name that is contained 
        /// in the request header. The only time LOGON_USER holds a different value than these other variables 
        /// is if you have an authentication filter installed.
        /// </summary>
        public const string LOGON_USER = "LOGON_USER";

        /// <summary>
        /// Path information, as given by the client, for example, "/vdir/myisapi.dll/zip". If this information comes from a 
        /// URL, it is decoded by the server before it is passed to the CGI script or ISAPI filter.  If the 
        /// AllowPathInfoForScriptMappings metabase property is set to true (to support exclusive CGI functionality), 
        /// PATH_INFO will only contain "/zip" and ISAPI applications such as ASP will break.
        /// </summary>
        public const string PATH_INFO = "PATH_INFO";

        /// <summary>
        /// The physical path that maps to the virtual path in PATH_INFO, for example, "c:\inetpub\wwwroot\vdir\myisapi.dll". 
        /// This variable is used by IIS during the processing of ISAPI applications. If the 
        /// AllowPathInfoForScriptMappings metabase property is set to true (to support exclusive CGI functionality), 
        /// PATH_INFO will only contain "/zip" and ISAPI applications such as ASP will break.
        /// </summary>
        public const string PATH_TRANSLATED = "PATH_TRANSLATED";

        /// <summary>
        /// Query information stored in the string following the question mark (?) in the HTTP request.
        /// </summary>
        public const string QUERY_STRING = "QUERY_STRING";

        /// <summary>
        /// The IP address of the remote host that is making the request.
        /// </summary>
        public const string REMOTE_ADDR = "REMOTE_ADDR";

        /// <summary>
        /// The name of the host that is making the request. If the server does not have this information, it will 
        /// set REMOTE_ADDR and leave this empty.
        /// </summary>
        public const string REMOTE_HOST = "REMOTE_HOST";

        /// <summary>
        /// The client port number of the TCP connection.
        /// </summary>
        public const string REMOTE_PORT = "REMOTE_PORT";

        /// <summary>
        /// The name of the user as it is derived from the authorization header sent by the client, before the user name 
        /// is mapped to a Windows account. If you have an authentication filter installed on your Web server that 
        /// maps incoming users to accounts, use LOGON_USER to view the mapped user name.
        /// </summary>
        public const string REMOTE_USER = "REMOTE_USER";

        /// <summary>
        /// The method used to make the request. For HTTP, this can be GET, HEAD, POST, and so on.
        /// </summary>
        public const string REQUEST_METHOD = "REQUEST_METHOD";

        /// <summary>
        /// A virtual path to the script being executed, for example, "/vdir/default.asp". This is used for 
        /// self-referencing URLs.
        /// </summary>
        public const string SCRIPT_NAME = "SCRIPT_NAME";

        /// <summary>
        /// The canonical physical path to the script listed in SCRIPT_NAME, for example, 
        /// "\\?\c:\inetpub\wwwroot\vdir\default.asp". 
        /// </summary>
        /// <remarks>
        /// IIS 5.1 and earlier: This server variable is not available.
        /// </remarks>
        public const string SCRIPT_TRANSLATED = "SCRIPT_TRANSLATED";

        /// <summary>
        /// The server's host name, DNS alias, or IP address as it would appear in self-referencing URLs.
        /// </summary>
        public const string SERVER_NAME = "SERVER_NAME";
        
        /// <summary>
        /// The server port number to which the request was sent.
        /// </summary>
        public const string SERVER_PORT = "SERVER_PORT";

        /// <summary>
        /// A string that contains either 0 or 1. If the request is being handled on the secure port, 
        /// then this is 1. Otherwise, it is 0.
        /// </summary>
        public const string SERVER_PORT_SECURE = "SERVER_PORT_SECURE";

        /// <summary>
        /// The name and revision of the request information protocol. The format is protocol/revision. 
        /// (The canonicalized form of HTTP_VERSION.)
        /// </summary>
        public const string SERVER_PROTOCOL = "SERVER_PROTOCOL";

        /// <summary>
        /// The name and version of the server software that answers the request and runs the gateway. The format is name/version.
        /// </summary>
        public const string SERVER_SOFTWARE = "SERVER_SOFTWARE";

        /// <summary>
        /// Returns a 1 if the server-side include directive, #exec, is disabled. Otherwise, SSI_EXE_DISABLED 
        /// returns a 0. To enable or disable #exec, use the SSIExecDisablemetabase property.
        /// </summary>
        /// <remarks>
        /// IIS 5.1 and earlier: This server variable is not available.
        /// </remarks>
        public const string SSI_EXEC_DISABLED = "SSI_EXEC_DISABLED";

        /// <summary>
        /// Returns the raw, unencoded URL, for example, "/vdir/default.asp?querystring".
        /// </summary>
        /// <remarks>
        /// IIS 4.0 and earlier: This server variable is not available.
        /// </remarks>
        public const string UNENCODED_URL = "UNENCODED_URL";

        /// <summary>
        /// The name of the user as it is derived from the authorization header sent by the client, before the 
        /// user name is mapped to a Windows account (same as REMOTE_USER). If you have an authentication filter 
        /// installed on your Web server that maps incoming users to accounts, use LOGON_USER to view the mapped user name.
        /// </summary>
        public const string UNMAPPED_REMOTE_USER = "UNMAPPED_REMOTE_USER";

        /// <summary>
        /// Gives the base portion of the URL, without any querystring or extra path information, for example, 
        /// "/vdir/default.asp". For the raw URL, use HTTP_URL or UNENCODED_URL.
        /// </summary>
        public const string URL = "URL";

        /// <summary>
        /// Use PATH_INFO instead.
        /// </summary>
        /// <remarks>
        /// Note: This server variable is only available on IIS 5.0.
        /// </remarks>
        public const string URL_PATH_INFO = "URL_PATH_INFO";
    }
}
